﻿'Programmé par Michel Gagnon
Public Class ListeBeneficiaire
    Dim oLocalContext As DBMainContext

    Private Sub ListeBeneficiaire_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        oLocalContext = New DBMainContext
        dgvBeneficiaire.DataSource = (From u In oLocalContext.Beneficiaire Where u.Actif = True Select u)
        dgvBeneficiaire.Columns("ID").Visible = False
        dgvBeneficiaire.Columns("DateNaissance").Visible = False
        dgvBeneficiaire.Columns("Adresse").Visible = False
        dgvBeneficiaire.Columns("CodePostal").Visible = False
        dgvBeneficiaire.Columns("Ville").Visible = False
        dgvBeneficiaire.Columns("Province").Visible = False
        dgvBeneficiaire.Columns("Photo").Visible = False
        dgvBeneficiaire.Columns("Note").Visible = False
        dgvBeneficiaire.Columns("Beneficiaire_Commentaire").Visible = False
        dgvBeneficiaire.Columns("Type_Beneficiaire").Visible = False
        dgvBeneficiaire.Columns("ID_TypeBeneficiaire").Visible = False
        dgvBeneficiaire.Columns("Actif").Visible = False
        dgvBeneficiaire.Columns("Type_BeneficiaireModif").DisplayIndex = 4
        dgvBeneficiaire.Columns("nom").Visible = False
        dgvBeneficiaire.Columns("prenom").Visible = False
        dgvBeneficiaire.Columns("NomComplet").DisplayIndex = 1
        dgvBeneficiaire.Columns("NomComplet").HeaderText = "Nom Complet"
        'dgvBeneficiaire.Columns("Bene").HeaderText = "Type"
        dgvBeneficiaire.Columns("Type_BeneficiaireModif").HeaderText = "Type"
        dgvBeneficiaire.Columns("DerniereEvaluation").HeaderText = "Dernière Évaluation"

    End Sub

    Private Sub btnAjouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAjouter.Click
        Dim oNewIBene As New GestionBeneficiaire()
        MainForm.AddTabToTC("Beneficiaire X", True, oNewIBene)
    End Sub

    Private Sub dgvBeneficiaire_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvBeneficiaire.DoubleClick
        Dim oBene As Beneficiaire
        oBene = CType(dgvBeneficiaire.SelectedRows(0).DataBoundItem, Beneficiaire)
        Dim oNewIBene As New GestionBeneficiaire(oBene)
        MainForm.AddTabToTC("Beneficiaire:" + oBene.Nom + "," + oBene.Prenom, True, oNewIBene)
    End Sub

    Private Sub btnOuvrir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOuvrir.Click
        Dim oBene As Beneficiaire
        oBene = CType(dgvBeneficiaire.SelectedRows(0).DataBoundItem, Beneficiaire)
        Dim oNewIBene As New GestionBeneficiaire(oBene)
        MainForm.AddTabToTC("Beneficiaire:" + oBene.Nom + "," + oBene.Prenom, True, oNewIBene)
    End Sub

    Private Sub dgvBeneficiaire_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvBeneficiaire.CellContentClick

    End Sub

    Private Sub ckActif_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ckActif.CheckedChanged
        dgvBeneficiaire.DataSource = (From u In oLocalContext.Beneficiaire Where u.Actif = Not ckActif.Checked Select u)

    End Sub
End Class
